package entity

import (
	"strconv"
	"time"

	"shqsoft.cn/pasnj/base"
	"shqsoft.cn/pasnj/bi/cube"
)

type CLIE_ZJL struct {
	ID        int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	Sjrq      *time.Time `gorm:"column:数据日期;type:date;"`
	Khmc      string     `gorm:"column:客户姓名;size:20"`
	Zjhm      string     `gorm:"column:证件号码;size:20"`
	Ckjb      string     `gorm:"column:持卡级别;size:20"`
	Khzcssjgh string     `gorm:"column:客户资产所属机构号;size:20"`
	Khzcssjg  string     `gorm:"column:客户资产所属机构;size:20"`
	Cxye      *float64   `gorm:"column:储蓄余额;"`
	Bblcye    *float64   `gorm:"column:保本理财余额;"`
	Fbblcye   *float64   `gorm:"column:非保本理财余额;"`
	Jjye      *float64   `gorm:"column:基金余额;"`
	Gzye      *float64   `gorm:"column:国债余额;"`
	Sgye      *float64   `gorm:"column:三管余额;"`
	Dsfdxye   *float64   `gorm:"column:第三方代销余额;"`
	CUID      int        `gorm:"column:CUID"`
	YG1       string     `gorm:"-"`
	ZB1       *float64   `gorm:"-"`
	YG2       string     `gorm:"-"`
	ZB2       *float64   `gorm:"-"`
	YG3       string     `gorm:"-"`
	ZB3       *float64   `gorm:"-"`
	YG4       string     `gorm:"-"`
	ZB4       *float64   `gorm:"-"`
	YG5       string     `gorm:"-"`
	ZB5       *float64   `gorm:"-"`
}

//TableName 表名
func (CLIE_ZJL) TableName() string {
	return "V_R_ASSET_GRADE_CUST_BAL_STAT"

}

// AfterFind 选择男女
func (c *CLIE_ZJL) AfterFind() (err error) {
	var share *cube.Share
	share, err = cube.GetShare("indi_clie_divi")
	if err != nil {
		return
	}
	var diviMap map[string]float64
	diviMap, err = share.GetDivision(strconv.Itoa(c.CUID))
	if err != nil {
		return
	}
	i := 0
	for k, v := range diviMap {
		val := v
		i++
		switch i {
		case 1:
			c.YG1 = k
			c.ZB1 = &val
		case 2:
			c.YG2 = k
			c.ZB2 = &val
		case 3:
			c.YG3 = k
			c.ZB3 = &val
		case 4:
			c.YG4 = k
			c.ZB4 = &val
		case 5:
			c.YG5 = k
			c.ZB5 = &val
		default:
			break
		}
	}
	return
}

//CLIE_ZJL 贵宾客户
func CLIE_ZJLEF() base.EntityFunc {
	return func() interface{} {
		entity := CLIE_ZJL{}
		return &entity
	}
}

//ZTXMCMXESF 交易贵金属
func CLIE_ZJLESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []CLIE_ZJL
		return &entities
	}
}
func init() {
	dao := base.NewDefaultDao(CLIE_ZJLEF(), CLIE_ZJLESF(), nil)
	filter := base.DefaultFilter{
		FilterColName: "CUID",
		TableName:     "T_INDI_CLIE_YGFC",
		EmidColName:   "emid",
		AcidColName:   "CUID",
		WhereCause:    "DTID=dbo.GetDateToInt(dbo.GetCurSysDate())",
	}
	dao.Fileter = &filter
	base.DaoPoolObj.Put("CLIE_ZJL", dao)
}
